/*
 * Copyright 2008 Hector Francisco Hernandez
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

var impactCanvas;
var impactArray = new Array();

function impactInit(canvas)
{
  impactCanvas = canvas;
}

function impactCreate(x, y)
{
  impactCanvas.innerHTML += "<img style=\"position:absolute; left:" + (x - 5) +
      "px; top:" + (y - 5) + "px\" src=\"impact.png\">";

  impactArray.push([x, y]);
}

function impactIsIn(x, y)
{
  for (n in impactArray) {
    dx = x - impactArray[n][0];
    dy = y - impactArray[n][1];
    dist = Math.sqrt(dx * dx + dy * dy);

    if (dist < 5) {
      return true;
    }
  }

  return false;
}

